$(function () {
    select_addr = function (obj) {
        var addr_info = $($(obj).children()).children();
        var name = $(addr_info[0]).html();
        var address = $(addr_info[1]).html();
        var phone = $(addr_info[2]).html();

        $("#shou_name").html(name);
        $("#shou_address").html(address);
        $("#shou_phone").html(phone)
    };

    return_shop_car = function () {
        location.href = '/shop/shopping_car'
    };

    create_order = function (obj) {
        var is_car = $(obj).attr('is_car');
        var express = $("input[name='radio']:checked");
        var express_type = $(express).attr('express-type');
        var comment = $("#comment").val();
        var pay_money = $("#shifu").html();
        if (!express_type) {
            alert('请选择快递方式');
            return;
        }
        var params = {
            'express': express_type,
            'comment': comment,
            'pay_money': pay_money,
        };
        $.ajax({
            url: "/shop/add_order?is_car=" + is_car,
            type: "post",
            data: JSON.stringify(params),
            contentType: "application/json"
        }).success(function (resp) {
            if (resp.errno == '0') {
                alert('已生成订单!');
                location.href = '/user/user_center'
            } else {
                alert(resp.errmsg)
            }
        })
    }

});